import { http } from "@/utils/http";
import { BaseRequest, Option, Result } from "@/api/index";

export type BusinessEntityAttributeVO = {
  id: string;
  businessEntityId: string;
  entityAttributeApi: string;
  entityAttributeJavaField: string;
  entityAttributeDescribe: string;
  entityAttributeType: string;
  genericType: string;
  referenceFlag: number;
  referenceApi: string;
  referenceTargetField: string;
  referenceShowField: string;
  dictFlag: number;
  vo: number;
  dto: number;
  po: number;
};

export const businessEntityAttributeVO = (businessEntityApi: string) => {
  return http.request<Result<Array<BusinessEntityAttributeVO>>>(
    http.GET,
    "/businessEntity/getEntityAttributeVO",
    { params: { businessEntityApi } }
  );
};
export const businessEntityAttributeDTO = (businessEntityApi: string) => {
  return http.request<Result<Array<BusinessEntityAttributeVO>>>(
    http.GET,
    "/businessEntity/getEntityAttributeDTO",
    { params: { businessEntityApi } }
  );
};
export const businessEntityAttributePO = (businessEntityApi: string) => {
  return http.request<Result<Array<BusinessEntityAttributeVO>>>(
    http.GET,
    "/businessEntity/getEntityAttributePO",
    { params: { businessEntityApi } }
  );
};
export const businessEntityAttributeFilterable = (
  businessEntityApi: string
) => {
  return http.request<Result<Array<BusinessEntityAttributeVO>>>(
    http.GET,
    "/businessEntity/getEntityAttributeFilterable",
    { params: { businessEntityApi } }
  );
};

export const businessEntityPageList = (data: BaseRequest) => {
  return http.request<Result<Array<any>>>(
    http.POST,
    "/businessEntity/pageList",
    { data }
  );
};

export const remoteSearchOption = (
  entityAttributeId: string,
  keyword: string
) => {
  return http.request<Result<Array<Option>>>(
    http.GET,
    "/businessEntity/remoteSearchOption",
    { params: { entityAttributeId, keyword } }
  );
};
